package com.navi.loaddata.loadService.impl.cellMappingData;

import com.navi.loaddata.core.gpEntity.hisToGP.ProductHis;
import com.navi.loaddata.core.mysqlEntity.EtlConfD;
import com.navi.loaddata.core.oracleEntity.fileMapping.Cell2ChipMappingT;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author jay
 */
@Service
public class ProcessCell2MappingDataService {
    public List<Cell2ChipMappingT> processCell2Mapping(EtlConfD etlConfD, List<ProductHis> glassList, HashMap<String,String> modelMap) {

        List<Cell2ChipMappingT> cell2List = new ArrayList<>();
        glassList.forEach(glass -> {
            Cell2ChipMappingT cell2Mapping = new Cell2ChipMappingT();
            cell2Mapping.setChipId(glass.getPanel_id());
            cell2Mapping.setArrayChipId(glass.getPanel_id());
            if (!StringUtils.isEmpty(modelMap.get(glass.getProd_id() + "_" + glass.getPanel_id().substring(10, 12)))) {
                cell2Mapping.setCfChipId(glass.getCfGlassName() + modelMap.get(glass.getProd_id() + "_" + glass.getPanel_id().substring(10, 12)));
            }else{
                cell2Mapping.setCfChipId("-1");
            }
            cell2List.add(cell2Mapping);
        });
        return cell2List;
    }
}
